<template>
  <div id="app" v-if="isRender">
<!--    <com-header-->
<!--      v-if="!$route.meta.hiddenHeader"-->
<!--      :title="$route.meta.title"-->
<!--      :nav-style="$route.meta.navStyle"-->
<!--    />-->
    <router-view v-if="!$route.meta.keepAlive" />
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive" />
    </keep-alive>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'App',
  data() {
    return {
    }
  },
  created() {
    // if (this.$route.query.token) {
    //   localStorage.setItem('UserToken', this.$route.query.token)
    // }
  },
  mounted() {
    // console.log(this.$route.query, 'this.$route.query.tokenthis.$route.query.token')
    // this.$store.dispatch('user/setUserInfo', {
    //   token: this.$route.query.token
    //   // token: this.$route.query.token || 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcwODU4NDk4MiwianRpIjoiOTkyMWMwOWItM2ZmYy00NjNlLWE2MmQtNGViMmU4N2ZmZmNmIiwidHlwZSI6Miwic3ViIjo0NjMzNzg2ODYyMjQ0NTQsIm5iZiI6MTcwODU4NDk4MiwiZXhwIjoxNzExMTc2OTgyfQ.8AbjPzrWzY1vZVq9logVKMufcRCjeDYZ8FIf7xsilIA'
    // })
  },
  computed: {
    ...mapGetters(['userInfo']),
    // 是否进行渲染，如果页面不需要校验token直接渲染，如果需要，等App回传token后渲染
    isRender() {
      return this.$route.meta.noAuth ? true : !!this.userInfo.token
    }
  },
  watch: {
    // '$route': {
    //   // immediate: true,
    //   deep: true,
    //   handler: function (value) {
    //   }
    // }
  }

}
</script>

<style lang="less">
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  width: 100% !important;
  height: 100%;
  font-size: 16px;
  background: #fff;
  box-sizing: border-box;
  max-width: 750px;
  margin: 0 auto;
}
</style>
